﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LambdaDemo
{
    public delegate int CalculatorDelegate(int x, int y);
    public delegate string SayHelloDelegate();
    class Program
    {
        static void Main(string[] args)
        {
            CalculatorDelegate c1 = delegate (int x, int y)
            {
                return x + y;
            };

            CalculatorDelegate c2 = (int x, int y) =>
            {
                return x + y;
            };

            CalculatorDelegate c3 = (x, y) =>
            {
                return x + y;
            };

            CalculatorDelegate c4 = (x, y) => x + y;

            CalculatorDelegate c5 = Cal5;


            SayHelloDelegate sayHello1 = delegate () { return "学习匿名与lamda"; };

            SayHelloDelegate sayHello2 = () => "学习匿名与lamda";
        }

        static int Cal5(int x, int y)
        {
            return x + y;
        }
    }
}